import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:app_core/app_core.dart';
import '../../../common/managers/theme_manager/theme_manager.dart';
import '../../../common/constant/colors.dart';
import '../../../common/constant/icon.dart';
import '../../../common/constant/styles.dart';

class DiscoverPage extends StatelessWidget {
  const DiscoverPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Get.theme.colorScheme.background,
      // appBar: APPBar.textBar(
      //   '发现',
      //   showBack: false,
      //   color: Get.theme.colorScheme.surface,
      //   titleColor: Get.theme.colorScheme.onSurface,
      //   right: AppGesture(
      //     onTap: () {
      //       Get.log('搜索');
      //     },
      //     child: Padding(
      //       padding: EdgeInsets.all(8),
      //       child: Icon(Icons.search, color: AppColor.white, size: 24),
      //     ),
      //   ),
      // ),
      body: SingleChildScrollView(
        padding: EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            _buildSectionTitle('智能设备'),
            SizedBox(height: 12),
            _buildDiscoverCard(
              title: '设备推荐',
              subtitle: '发现更多智能设备',
              icon: Icons.devices_other,
              color: AppColor.info,
            ),
            _buildDiscoverCard(
              title: '热门设备',
              subtitle: '大家都在用的设备',
              icon: Icons.trending_up,
              color: AppColor.success,
            ),
            
            SizedBox(height: 16),
            
            _buildSectionTitle('智能场景'),
            SizedBox(height: 8),
            _buildDiscoverCard(
              title: '场景模式',
              subtitle: '一键设置智能场景',
              icon: Icons.auto_awesome,
              color: AppColor.secondary,
            ),
            _buildDiscoverCard(
              title: '场景模板',
              subtitle: '使用预设场景模板',
              icon: Icons.dashboard,
              color: AppColor.primary,
            ),
            
            SizedBox(height: 16),
            
            _buildSectionTitle('学习交流'),
            SizedBox(height: 8),
            _buildDiscoverCard(
              title: '使用技巧',
              subtitle: '学习设备使用技巧',
              icon: Icons.school,
              color: AppColor.warning,
            ),
            _buildDiscoverCard(
              title: '社区分享',
              subtitle: '与其他用户交流经验',
              icon: Icons.people,
              color: AppColor.success,
            ),
            _buildDiscoverCard(
              title: '最新资讯',
              subtitle: '了解智能家居最新动态',
              icon: Icons.newspaper,
              color: AppColor.error,
            ),
            
            SizedBox(height: 16),
            
            _buildSectionTitle('服务支持'),
            SizedBox(height: 8),
            _buildDiscoverCard(
              title: '在线客服',
              subtitle: '获取专业帮助',
              icon: Icons.support_agent,
              color: AppColor.primary,
            ),
            _buildDiscoverCard(
              title: '维修服务',
              subtitle: '设备维修和保养',
              icon: Icons.build,
              color: AppColor.textSecondary,
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildSectionTitle(String title) {
    return Text(
      title,
      style: AppStyles.s16w5.copyWith(color: Get.theme.colorScheme.primary),
    );
  }

  Widget _buildDiscoverCard({
    required String title,
    required String subtitle,
    required IconData icon,
    required Color color,
  }) {
    return Container(
      margin: EdgeInsets.only(bottom: 8),
      decoration: BoxDecoration(
        color: Get.theme.colorScheme.surface,
        borderRadius: BorderRadius.circular(12),
      ),
      child: AppGesture(
        onTap: () {
          Get.snackbar('提示', '$title 功能开发中...');
        },
        child: Padding(
          padding: EdgeInsets.all(16),
          child: Row(
            children: [
              Container(
                width: 48,
                height: 48,
                decoration: BoxDecoration(
                  color: color.withOpacity(0.1),
                  borderRadius: BorderRadius.circular(12),
                ),
                child: Icon(
                  icon,
                  color: color,
                  size: 24,
                ),
              ),
              SizedBox(width: 16),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      title,
                      style: AppStyles.s16w5,
                    ),
                    SizedBox(height: 4),
                    Text(
                      subtitle,
                      style: AppStyles.s14.copyWith(color: Get.theme.colorScheme.onSurface.withOpacity(0.6)),
                    ),
                  ],
                ),
              ),
              Icon(
                Icons.arrow_forward_ios,
                size: 16,
                color: Get.theme.colorScheme.onSurface.withOpacity(0.6),
              ),
            ],
          ),
        ),
      ),
    );
  }
} 